$j = $;

$j(function() {
    $j('.gotoLocation').click( function () {
        var location = $j( this ).attr('rel');
        if ( typeof (location) !== 'undefined' && location.length ) {
            window.location = location;
        }
    });
});

/*-----------------------------------------------------------------------------
  FUNCTIONS
-----------------------------------------------------------------------------*/
function showLoading(args) {
    if ( args.show ) {
        $j(args.id).html('<i class="fa fa-spinner fa-spin fa-lg"></i>');
    } else {
        $j(args.id).html('');
    }
}

function showAlert(params) {
    var dialog = $j('#dialog-alert');

    if ( params.title !== undefined ) {
        dialog.find('.modal-title').text(params.title);
    }
    dialog.find('.modal-body').html(params.message);
    dialog.modal('show');
}

function showConfirm(params) {
    var dialog = $j('#dialog-confirm');

    if ( params.title !== undefined ) {
        dialog.find('.modal-title').text(params.title);
    }
    if ( params.message !== undefined ) {
        dialog.find('.modal-body').html(params.message);
    }
    if ( params.callback !== undefined ) {
        dialog.find('#btn-yes').attr('onclick', params.callback);
    }
    dialog.modal('show');
}

function openContactDialog() {
    var dialog = $j('#dialog-contact');
    dialog.modal('show');
}

function openDialogIframe( args ) {
    var dialog = $j('#dialog-iframe');
    var data = '';

    if ( args.height !== undefined ) {
        dialog.find('iframe').attr( 'height', args.height );
    }

    if ( args.title !== undefined ) {
        dialog.find('.modal-title').html( args.title );
    }

    if ( args.data !== undefined ) {
        data = '?' + $j.param( args.data );
    }

    dialog.find('iframe').attr( 'src', args.src + data);
    dialog.modal('show');
    return true;
}

function closeDialogIframe() {
    $j('#dialog-iframe').modal('hide');
    return true;
}
/*-----------------------------------------------------------------------------
  .FUNCTIONS
-----------------------------------------------------------------------------*/